<?php
date_default_timezone_set("Asia/Shanghai");
if(!empty($_POST['submit'])){
      require './class.phpmailer.php';
      try {
        $mail = new PHPMailer(true); //实例化一个邮件类
        $mail->CharSet = "utf-8"; //设置字符编码
        $mail->IsSMTP();          //使用smtp协议
        $mail->SMTPAuth   = true;  // 激活SMTP 授权验证
        $mail->Port       = 25;     // 设置smtp端口号
        $mail->Host       = "smtp.163.com"; // SMTP 服务器地址
        $mail->Username   = "m18742129593@163.com";     // SMTP 服务帐号
        $mail->Password   = "QYX11111";            // SMTP 服务密码
        $mail->From       = "m18742129593@163.com"; //自己的邮箱
        $mail->FromName   = "jack"; //自己的名字

        $body = $_POST['content'];  //发送的内容
        $to = $_POST['to']; //发送给谁
        $mail->AddAddress($to);
        $mail->Subject  = $_POST['title']; //发送主题
        $mail->MsgHTML($body);
        $mail->IsHTML(true); // 作为html发送
        $mail->Send();
        echo '邮件已发送';
     }catch (phpmailerException $e) {
        echo $e->errorMessage();
    }
}



?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
      <form action="" method="post">
        <p>标题:<input type="text" name="title"></p>
        <p>收件人：<input type="text" name="to"></p>
        <p>内容：<textarea name="content" id="" cols="30" rows="10"></textarea></p>
        <p><input type="submit" name="submit" value="发送"></p>
      </form>
</body>
</html>